 $LOAD_PATH.unshift File.join(File.dirname(__FILE__),'../..','ext_pr1/lib')
 require 'ext_pr1_v4'
# larger_sum_square ::= (val1, val2, val3) :: Int x Int x Int -> Int
# returns the 2 biggest objects
# Test {(1, 2, 3)=>13, (3, 2, 1)=>13, (2, 1, 3)=>13, (2, 3, 1)=>13,
# (1, 3, 2)=>13, (3, 1, 2)=>13, (1, 1, 1)=>Err, (1, 1, 2)=>Err, 
# (1, 1, 3)=>Err, (2, 2, 2)=>Err, (2, 2, 1)=>Err, (2, 2, 3)=>Err,
# (3, 3, 3)=>Err, (3, 3, 2)=>Err, (3, 3, 1)=>Err}
def larger_sum_square(val1, val2, val3)
  check_pre((val1 != val2 and val2 != val3 and val2 != val3))
  biggest_numbers = find_two_biggest_object(val1, val2, val3)
  ((biggest_numbers[0]**2) + (biggest_numbers[1]**2))
  
end

def find_two_biggest_object(val1, val2, val3)
  biggest_numbers = Array.new
  
  if val1 > val2
    biggest_numbers[0] = val1
     biggest_numbers[1] = val2
  else 
    biggest_numbers[0] = val2
    biggest_numbers[1] = val1
  end
  
  if biggest_numbers[1] < val3
    biggest_numbers[1] = val3
  end
  biggest_numbers
end

#def find_two_biggest_object(val1, val2, val3)
# 
#  
#  if val1 > val2 then [val1,val2]
#    biggest_numbers[0] = val1
#     biggest_numbers[1] = val2
#  else 
#    biggest_numbers[0] = val2
#    biggest_numbers[1] = val1
#  end
#  
#  if biggest_numbers[1] < val3
#    biggest_numbers[1] = val3
#  end
#  biggest_numbers
#  
#  max_v1_v2 = (val1 > val2 ? val1 : val2)
#  
#  [(val1 > val2 ? val1 : val2), (val1 > val2 ? val2 : val1) < val3 ? val3 : mmmmmm ]
#end